package org.example.juc.condition;

import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author songyafei
 */
public class ConditionConAndProTest {
    public static void main(String[] args) {


        Queue<String> queue = new LinkedList<>();
        int maxSize = 10;
        Lock lock = new ReentrantLock();
        Condition condition = lock.newCondition();

        Producer producer = new Producer(queue,maxSize,lock,condition);
        Consumer consumer = new Consumer(queue,maxSize,lock,condition);

        Thread t1 = new Thread(producer);
        Thread t2 = new Thread(consumer);
        t1.start();
        t2.start();
    }
}
